package com.project.weimi.adapter;

import java.util.List;

import com.project.weimi.R;
import com.project.weimi.entity.response.HotInvitationEntity;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class HotInvitationAdapter extends BaseAdapter{

	private Context context;
	private List<HotInvitationEntity> hotList;
	
	public HotInvitationAdapter(Context context, List<HotInvitationEntity> hotList) {
		super();
		this.context = context;
		this.hotList = hotList;
	}

	@Override
	public int getCount() {
		return hotList.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		if(convertView == null){
			vh = new ViewHolder();
			// 解析布局文件
			convertView = LayoutInflater.from(context).inflate(R.layout.hotinvitation_listview_item, null);
			// 从布局文件获得控件对象
			vh.img_hotInvitation = (ImageView)convertView.findViewById(R.id.img_hotInvitation);
			vh.tv_title = (TextView)convertView.findViewById(R.id.tv_title);
			vh.tv_content = (TextView)convertView.findViewById(R.id.tv_content);
			convertView.setTag(vh);
		}else{
			vh = (ViewHolder) convertView.getTag();
		}
		
		vh.img_hotInvitation.setImageResource(hotList.get(position).getImg());
		vh.tv_title.setText(hotList.get(position).getTitle());
		vh.tv_content.setText(hotList.get(position).getContent());
		
		
		return convertView;
	}

	class ViewHolder{
		ImageView img_hotInvitation;
		TextView tv_title;
		TextView tv_content;
	}
	
	
	
}
